package com;
import com.MD5;
import java.sql.*;
public class Auth {

	public static boolean check(String username,String pwd) {
		System.out.println("in Auth.check()...");
		
		//获得数据库连接
		try {
			Class.forName("org.mariadb.jdbc.Driver");
			String url = "jdbc:mariadb://localhost:3306/epidemicmanagement";
			Connection conn = DriverManager.getConnection(url,"root","123456");
			Statement stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery("select*from user");
			
			while(rs.next()) {
				String usernum = rs.getString("UserNum");
				String userpwd = rs.getString("UserPwd");
				if(usernum.equals(username)&&userpwd.equals(pwd)) {
					return true;
				}
			}
		}catch (ClassNotFoundException| SQLException e) {
			e.printStackTrace();
		}
		
		//创建查询语句
		return false;
	}

}
